package top.minuy.algorithm.sort.bubble;

import top.minuy.util.constant.SortType;
import top.minuy.util.generate.ArrayGenerator;
import top.minuy.util.helper.SortingHelper;

import java.util.Arrays;

/**
 * 冒泡排序算法测试
 *
 * @author Minuy
 * @time 10:1
 * @date 2021/9/28
 */
public class Test {
    public static void main(String[] args) {
        Integer[] arr = {3, 4, 5, 7, 2, 1, 5, 9};
        BubbleSort.sort(arr);
        for (Integer i : arr) {
            System.out.print(i + " ");
        }

        System.out.println();

        System.out.println("性能测试：");

        int n = 24000;
        System.out.println("随机数据：");
        Integer[] aa = ArrayGenerator.generateRandomArray(n, n);
        Integer[] ab = Arrays.copyOf(aa, aa.length);
        Integer[] ac = Arrays.copyOf(aa, aa.length);
        SortingHelper.SortTest(SortType.BubbleSort, aa);
        SortingHelper.SortTest(SortType.BubbleSort1, ab);
        SortingHelper.SortTest(SortType.BubbleSort2, ac);

        System.out.println("有序数据：");
        Integer[] ba = ArrayGenerator.generateOrderedArray(n, n);
        Integer[] bb = Arrays.copyOf(ba, ba.length);
        Integer[] bc = Arrays.copyOf(ba, ba.length);
        SortingHelper.SortTest(SortType.BubbleSort, ba);
        SortingHelper.SortTest(SortType.BubbleSort1, bb);
        SortingHelper.SortTest(SortType.BubbleSort2, bc);
    }
}
